
//==============================================================================
//File:	CGame.h
//Desc: This is the main demo/game application class.  This is where all the
//		application processing will take place.  The grand central station.
//	
//	I will be commenting the hell out of every file.  We can build after each
//	lesson and delete what conflicts.  This is the working project.
//Copyright this shit.  Asad Aslam, Aaron Raines. (Demo Purposes) :)
//=============================================================================
#ifndef _CGAME_H_
#define _CGAME_H_

//=============================================================================
//CGame Includes
//=============================================================================

#include "Main.h"
#include "CTimer.h"
#include "CObject.h"

//============================================================================
//All Major Class Declarations Follow
//============================================================================

//============================================================================
//Name: CGame(Class)
//Desc: Game engine, initialize the game and handle all core processes.
//============================================================================
class CGame
{
public:
	//=======================================================================
	//Constructors and Destructors
	//=======================================================================
	CGame();
	virtual ~CGame(); //Virtual destructors ftw! Thanks Meyers

	//=======================================================================
	//All public functions
	//=======================================================================
	LRESULT	DisplayWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
	bool	InitInstance(HANDLE hInstance, LPCTSTR lpCmdLine, int iCmdShow);
	int		BeginGame();
	bool	ShutDown();

private:
	//=======================================================================
	//All private functions
	//=======================================================================
	bool	BuildObjects();			//this is just the cube
	void	FrameAdvance();			
	bool	CreateDisplay();		//create the window and the handle. call InitDirect3D() with the new handle.
	void	SetupGameState();		
	void	SetupRenderStates();	
	void	AnimateObjects();		
	void	ProcessInput();			
	bool	InitDirect3D();			
	D3DFORMAT	FindDepthStencilFormat(ULONG AdapterOrdinal, D3DDISPLAYMODE Mode, D3DDEVTYPE DevType);

	//======================================================================
	//Private Static Function
	//======================================================================
	static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);

	//======================================================================
	//Private Variables
	//======================================================================
	D3DXMATRIX				m_viewMatrix;			//View Matrix
	D3DXMATRIX				m_projectionMatrix;		//Projection Matrix

	CMesh					m_Mesh;					//Mesh we want to render
	COjbect					m_pObject[2];			//Objects that will store the mesh

	CTimer					m_Timer;				//Game Timer

	HWND					m_hWnd;					//Main window HWND

	bool					m_bLostDevice;			//3D Device lost?
	bool					m_bActive;				//Is the application active?
	bool					m_bRotation1;			//Object 1 rotation on/off
	bool					m_bRotation2;			//Object 2 rotation on/off

	ULONG					m_nViewX;				//X Position of render viewport
	ULONG					m_nViewY;				//Y Positions of render viewport
	ULONG					m_nViewWidth;			//Width of render viewport
	ULONG					m_nViewHeight;			//Height of render viewport

	LPDIRECT3D9				m_pD3D;					//Direct3D Object
	LPDIRECT3DDEVICE9		m_pD3DDevice;			//Direct3D Device Object
	D3DPRESENT_PARAMTERS	m_D3DPresentParams;		//Direct3D Present Parameters

};

#endif //_CGAME_H_